package com.mk.datapower.bean.page;

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author: peisong.chen
 * @Date: 2019/9/16
 * @Content:
 */
public class PageImpl<T> extends PageData<T> implements Page<T> {

    /**
     * 额外返回参数
     */
    private List<String> secondList;
    public PageImpl() {
    }

    public PageImpl(long count, List<T> list) {
        super.setCount(count);
        super.setList(list);
    }

    public PageImpl(long count, List<T> list, List<String> secondList) {
        super.setCount(count);
        super.setList(list);
        this.setSecondList(secondList);
    }

    @Override
    public <U> PageImpl<U> map(Function<? super T, ? extends U> converter) {
        List<U> collect = super.list.stream()
                .map(converter)
                .collect(Collectors.toList());
        return new PageImpl<>(super.count, collect);
    }

    public void setSecondList(List<String> secondList) {
        this.secondList = secondList;
    }
}
